package com.xqx.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author：xingquanxiang createTime：2019/10/4 12:46
 * description:
 */
public class DateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String s) {
        // 将日期字符串转换为日期对象
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = null;
        try {
            parse = simpleDateFormat.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}
